from django.conf.urls.defaults import *
from os.path import abspath, dirname

from django.contrib import admin
admin.autodiscover()

path_to_media = '%s/media/' % dirname(abspath(__file__))

# MEDIA Y ADMIN
urlpatterns = patterns('',
    (r'^admin/(.*)', admin.site.root),
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': path_to_media }),
)

# INDEX LOGUEADO
urlpatterns += patterns('index.views',
    (r'^$', 'index'),
    (r'^login/join/$', 'join'),
    (r'^login/$', 'start_session'),
    (r'^logout/$', 'close_session'),
    (r'^building/$', 'building'),
)

# STAFF
urlpatterns += patterns('staff.views',
    (r'^staff/clients/register/$', 'clients_register'),
    (r'^staff/clients/$', 'clients'),
    (r'^staff/clients/(?P<id_cl>\d+)/$', 'clients_detail'),
    (r'^staff/clients/(?P<id_cl>\d+)/payment/$', 'clients_payment'),
    (r'^staff/clients/(?P<id_cl>\d+)/payment/pay/$', 'clients_pay'),
    (r'^staff/$', 'index'),
    (r'^staff/vendors/$', 'vendors'),
    (r'^staff/vendors/register/$', 'vendors_register'),
    (r'^staff/vendors/delete/(?P<id_vendor>\d+)/$', 'vendors_delete'),
    (r'^staff/providers/$', 'providers'),
    (r'^staff/providers/register/$', 'providers_register'),
     )

# INVENTORY
urlpatterns += patterns('inventory.views',
    (r'^warehouse/$', 'inventory_warehouse'),
    (r'^warehouse/register/$', 'inventory_warehouse_register'),
    (r'^warehouse/delete/(?P<id_wh>\d+)/$', 'inventory_warehouse_delete'),
    (r'^itemtemplate/$', 'inventory_itemtemplate'),
    (r'^itemtemplate/register/$', 'inventory_itemtemplate_register'),
    (r'^itemtemplate/(?P<id_it>\d+)/$', 'inventory_itemtemplate_detail'),
    (r'^itemtemplate/(?P<id_it>\d+)/register/$', 'inventory_itemtemplate_itemregister'),
    (r'^itemtemplate/delete/(?P<id_it>\d+)/$', 'inventory_itemtemplate_delete'),
    (r'^itemtemplate/search/(?P<text>\w+)/$', 'inventory_itemtemplate_search'),
    (r'^itemtemplate/load/(?P<id_template>\d+)/$', 'inventory_itemtemplate_load'),
    (r'^item/delete/(?P<id_i>\d+)/(?P<id_it>\d+)/$', 'inventory_item_delete'),
    (r'^item/(?P<id_i>\d+)/$', 'inventory_item_home'),
    (r'^item/search/(?P<text>\w+)/$', 'inventory_item_search'),
    (r'^item/get/(?P<id_item>\d+)/$', 'inventory_item_get'),
    (r'^obtainment/$', 'inventory_obtainment'),
    (r'^obtainment/register/$', 'inventory_obtainment_register'),
    (r'^obtainment/close/(?P<id_obt>\d+)/$', 'inventory_obtainment_close'),
    (r'^obtainment/delete/(?P<id_obt>\d+)/$', 'inventory_obtainment_delete'),
    (r'^currency/$', 'inventory_currency'),
    (r'^currency/register/$', 'inventory_currency_register'),
    (r'^currency/modify/$', 'inventory_currency_modify'),
    (r'^vinyl/$', 'inventory_vinyl'),
    (r'^vinyl/register/$', 'inventory_vinyl_register'),
    (r'^vinyl/delete/(?P<id_vinyl>\d+)/$', 'inventory_vinyl_delete'),
    (r'^vinyl/search/(?P<text>\w+)/$', 'inventory_vinyl_search'),
    (r'^vinyl/(?P<id_vinyl>\d+)/$', 'inventory_vinyl_detail'),
    (r'^vinyl/(?P<id_vinyl>\d+)/add/$', 'inventory_vinyl_add'),
    (r'^vinyl/get/(?P<id_vinyl>\d+)/$', 'inventory_vinyl_get'),
    (r'^wheel/$', 'inventory_wheel'),
    (r'^wheel/register/$', 'inventory_wheel_register'),
    (r'^wheel/delete/(?P<id_wheel>\d+)/$', 'inventory_wheel_delete'),
    (r'^wheel/search/(?P<text>\w+)/$', 'inventory_wheel_search'),
    (r'^wheel/(?P<id_wheel>\d+)/$', 'inventory_wheel_detail'),
    (r'^wheel/(?P<id_wheel>\d+)/add/$', 'inventory_wheel_add'),
    (r'^wheel/get/(?P<id_wheel>\d+)/$', 'inventory_wheel_get'),
    (r'^currency/all/$', 'inventory_currencies'),
    )

# SALES
urlpatterns += patterns('exchanges.views',
    (r'^sales/$', 'sales_home'),
    (r'^sales/sell/$', 'sales_sell'),
    (r'^reports/$', 'reports_home'),
    (r'^reports/sales/$', 'reports_sales'),
    (r'^reports/sales/(?P<id_sale>\d+)/$', 'report_sale_show'),
    (r'^reports/dailysales/', 'daily_sales'),
    )
